package day16.tarena.GUI;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;

public class TestText implements ActionListener {
	JTextField jtf1 = new JTextField(10);
	JTextField jtf2 = new JTextField(10);

	public void actionPerformed(ActionEvent e) {
		String aa = jtf1.getText(), bb =jtf2.getText();
		jtf1.setText(bb);
		jtf2.setText(aa);
	}
	
	public TestText(){
		JFrame jf =new JFrame("TestText!");
		JButton jb = new JButton("交换位置");
		FlowLayout fl = new FlowLayout();
		jf.setLayout(fl);
		jf.add(jtf1);
		jf.add(jb);
		jf.add(jtf2);
		jb.addActionListener(this);
		jf.setLocation(400,200);
		jf.setSize(400,200);
		jf.setVisible(true);
		jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}
	
	public static void main(String[] args) {
		new TestText();
	}
}    